<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>设备添加</title>
</head>
{% include 'admin/common/header.html' %}
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="criminal_id" lay-verify="title" autocomplete="off" placeholder="请输入编号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="title" autocomplete="off" placeholder="请输入姓名"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="text" name="sex" lay-verify="title" autocomplete="off" placeholder="请输入性别"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">身份证号</label>
                    <div class="layui-input-block">
                        <input type="text" name="identify" lay-verify="title" autocomplete="off" placeholder="请输入身份证号"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">严管类型</label>
                    <div class="layui-input-block">
                        <input type="text" name="control_type" lay-verify="title" autocomplete="off" placeholder="请输入严管类型"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">住址</label>
                    <div class="layui-input-block">
                        <input type="text" name="adrss" lay-verify="title" autocomplete="off" placeholder="请输入住址"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">罪名</label>
                    <div class="layui-input-block">
                        <input type="text" name="charge" lay-verify="title" autocomplete="off" placeholder="请输入罪名"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">所属监区</label>
                    <div class="layui-input-block">
                        <input type="text" name="subordi_jur" lay-verify="title" autocomplete="off" placeholder="请输入监区"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">籍贯</label>
                    <div class="layui-input-block">
                        <input type="text" name="native_place" lay-verify="title" autocomplete="off" placeholder="请输入籍贯"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">UWB-SN</label>
                    <div class="layui-input-block">
                        <input type="text" name="UWB_SN" lay-verify="title" autocomplete="off" placeholder="请输入UWB_SN"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">GPS_SN</label>
                    <div class="layui-input-block">
                        <input type="text" name="GPS_SN" lay-verify="title" autocomplete="off" placeholder="请输入GPS_SN"
                               class="layui-input">
                    </div>
                </div>


            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="equip-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
{% include 'admin/common/footer.html' %}
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form
    let $ = layui.jquery
    form.on('submit(equip-save)', function (data) {
      let roleIds = ''
      $('input[type=checkbox]:checked').each(function () {
        roleIds += $(this).val() + ','
      })
      roleIds = roleIds.substr(0, roleIds.length - 1)
      data.field.roleIds = roleIds

      $.ajax({
        url: '/criminal/info/save',
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (result) {
          if (result.success) {
            layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
              parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
              parent.layui.table.reload('monitor_equip_list-table')
            })
          } else {
            layer.msg(result.msg, { icon: 2, time: 1000 })
          }
        }
      })
      return false
    })
  })
</script>
</body>
</html>